package cn.jiedanba.cacert.caadmin.config;

import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.github.pagehelper.PageInterceptor;
import com.mybatisflex.core.keygen.KeyGeneratorFactory;

import cn.jiedanba.cacert.common.mapperflex.ext.genId.SnowflakeGenId;

@Configuration
@MapperScan(basePackages = "cn.jiedanba.cacert.mapper*")
public class MyBatisFlexConfiguration {

	private static final Logger logger = LoggerFactory.getLogger("mybatis-flex-sql");

	public MyBatisFlexConfiguration() {

		/*
		 * // 开启审计功能 AuditManager.setAuditEnable(true);
		 * 
		 * // 设置 SQL 审计收集器
		 * 
		 * AuditManager.setMessageCollector( auditMessage ->
		 * logger.info("{},{}ms", auditMessage.getFullSql(),
		 * auditMessage.getElapsedTime()));
		 */
		KeyGeneratorFactory.register("snowflake", new SnowflakeGenId());

	}

	@Bean
	public PageInterceptor pageInterceptor() {
		PageInterceptor i = new PageInterceptor();
		return i;
	}

}
